﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;

namespace Bussiness_Objects
{
    /// <summary>
    /// thong tin table CT_TACGIA
    /// ---CT_TACGIA(MaDauSach,MaTacGia)
    /// </summary>
    public class CTTacGia : BusinessObjects
    {
        public CTTacGia()
        {
            
        }

        public CTTacGia(int _maTg, int _maDauSach)
        {
            MaTacGia = _maTg;
            MaDauSach = _maDauSach;
        }

        public override void SetParameterInsert()
        {
            parms = new object[2];
            SqlParameter _parm = new SqlParameter(parMaDauSach, MaDauSach);
            parms[0] = _parm;

            _parm = new SqlParameter(parMaTacGia, MaTacGia);
            parms[1] = _parm;
        }

        public void SetParameterDelete()
        {
            SetParameterInsert();
        }

        public void SetParameterSelectByKey()
        {
            SetParameterInsert();
        }

        public void SetParameterSelectByAuthor()
        {
            parms = new object[1];
            SqlParameter _parm = new SqlParameter(parMaDauSach, MaDauSach);
            parms[0] = _parm;
        }

        public void SetParameterSelectByIDSach()
        {
            parms = new object[1];
            SqlParameter _parm = new SqlParameter(parMaTacGia, MaTacGia);
            parms[0] = _parm;
        }

        public void SetDataUpdate(int _maDauSach, int _maTg)
        {
            MaDauSach_new = _maDauSach;
            MaTacGia_new = _maTg;
        }

        public override void SetParameterUpdate()
        {
            parms = new object[4];
            SqlParameter _parm = new SqlParameter(parMaDauSach + "_old", MaDauSach);
            parms[0] = _parm;

            _parm = new SqlParameter(parMaTacGia + "_old", MaTacGia);
            parms[1] = _parm;

            _parm = new SqlParameter(parMaDauSach + "_new", MaDauSach_new);
            parms[2] = _parm;

            _parm = new SqlParameter(parMaTacGia + "_new", MaTacGia_new);
            parms[3] = _parm;
        }

        public int MaDauSach { get; set; }
        private const string parMaDauSach = "@MaDauSach";
        public int MaDauSach_new { get; set; }

        public int MaTacGia { get; set; }
        private const string parMaTacGia = "@MaTacGia";
        public int MaTacGia_new { get; set; }
    }
}
